package com.cnblsp2.android.study.androidresources.anim;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

import com.cnblsp2.android.study.androidresources.R;

public class MyAnimActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_anim);

		final ImageView image = (ImageView) this.findViewById(R.id.activity_anim_image);

		// 加载动画资源
		final Animation animation = AnimationUtils.loadAnimation(this, R.anim.my_anim);

		// 设置动画结束后保留结束状态
		animation.setFillAfter(false);

		Button button = (Button) this.findViewById(R.id.activity_anim_startanim);
		button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 开始动画
				image.startAnimation(animation);
			}
		});

	}

}
